﻿using DataModels.Dto;
using DataModels.Dto.AuthCore;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.Mvc;
using Services.AuthCore;
using Services.WorkOrder;
using System.Net;
using Utils;

namespace PropertyManagementWebApi.Controllers.AuthCore
{
    public class UserController(UserService userService) : BaseController
    {
        protected readonly UserService _userService = userService;

        /// <summary>
        /// 获取登录用户的信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetUserInfo()
        {
            return _userService.GetUserInfo();
        }

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel EditUserInfo(EditUserInfo userinfo)
        {
            return _userService.EditUserInfo(userinfo);
        }

        /// <summary>
        /// 获取商户登录用户的信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetMerchantsUserInfo()
        {
            return _userService.GetMerchantsUserInfo();
        }

        /// <summary>
        /// 修改商户用户信息
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel EditMerchantsUserInfo(EditUserInfo userinfo)
        {
            return _userService.EditMerchantsUserInfo(userinfo);
        }

        /// <summary>
        /// 获取收货地址信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResponseModel> GetDeliveryAddressAsync()
        {
            return await _userService.GetDeliveryAddress();
        }

        /// <summary>
        /// 添加地址
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> AddDeliveryAddress(AddDeliveryAddress info)
        {
            return await _userService.AddDeliveryAddress(info);
        }

        /// <summary>
        /// 修改地址
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> SetDeliveryAddress(AddDeliveryAddress info)
        {
            return await _userService.SetDeliveryAddress(info);
        }

        /// <summary>
        /// 删除地址
        /// </summary>
        /// <param name="UUID"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> DelDeliveryAddress(DelDeliveryAddress info)
        {
            return await _userService.DelDeliveryAddress(info.UUID);
        }


        /// <summary>
        /// 获取支付优惠券信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResponseModel> GetPaymentCoupon([FromQuery] GetPaymentCouponInfo info)
        {
            return await _userService.GetPaymentCoupon(info);
        }

      
        /// <summary>
        /// 通过角色名获取用户（业主）
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetObtainUsers_owners_through_role([FromQuery] string crolename)
        {
            return _userService.GetObtainUsers_owners_through_role(crolename);
        }

        /// <summary>
        /// 当前人员是否为指定角色
        /// </summary>
        /// <param name="RoleName"> 输入角色名</param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel WhetherPersonSpecifiedRole(string RoleName)
        {
            return _userService.WhetherPersonSpecifiedRole(RoleName);
        }

    }

}
